package com.wing.sell.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.sell.dao.AgentDueEnclosureDao;
import com.wing.sell.model.entity.AgentDueEnclosure;
import com.wing.sell.model.request.AgentDueEnclosureForm;
import com.wing.sell.model.response.AgentDueEnclosureVO;
import com.wing.sell.service.AgentDueEnclosureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 代理经销商尽调记录表-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class AgentDueEnclosureServiceImpl extends ServiceImpl<AgentDueEnclosureDao, AgentDueEnclosure> implements AgentDueEnclosureService {

    @Override
    public int add(AgentDueEnclosureForm agentDueEnclosureForm) {

        //校验

        AgentDueEnclosure agentDueEnclosure =new AgentDueEnclosure();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(AgentDueEnclosure.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(agentDueEnclosureForm, agentDueEnclosure, copyOptions);

        return baseMapper.insert(agentDueEnclosure);
    }

    @Override
    public List<AgentDueEnclosureVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<AgentDueEnclosureVO> pageList4app(Page page, Map<String, Object> params) {
        List<AgentDueEnclosureVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public AgentDueEnclosureVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }
}
